<include file="Public/head"/>

<style type="text/css">
    .getCode {
        display: inline-block;
        width: 40%;
        text-align: right;
        color: #2cd0da;
    }
.inputys{background-color:rgba(255,255,255,0); height:50px;outline: none; border:0px; color:#333;width:100%;}
</style>

<body style="padding-top: 38px">
    <div class="title1" >      
        <div class=" col-xs-4" style="text-align:left">
            <a href="{:U('Finance/wallet')}" style="color:#333">
                <span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span>
            </a>
        </div> 
        <div class=" col-xs-4"> {:L('_TB_')}</div> 
        <div class=" col-xs-4"></div> 
    </div> 

    <div class="container" style=" padding-top:40px;">

<!--         <div class="row-fluid qk" > 
            <div style=" height:50px; line-height:50px; font-size:16px; ">  
                <div style=" float:left; padding-left:15px;"><img src="__IMG__/B.png" width="30" /></div>
                <div style="float:left; width:45%; padding-left:15px; color:#FFF;">
                    BTC
                </div> 
                  
                <div style=" float:right; padding-right:15px; text-align:right; color:#475377;">
                    <span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span>
                </div>
            </div> 
        </div> -->

        <div class="row-fluid qk" >

                <div class="choose" style=" height:50px;">
                    <select class="form-control" style="margin-top: 5px;background-color: #F1F3F4;border: 1px solid #475377;" id="coinname">
                        <!--<select name="" id="charge">-->
                        <!--<option value="1">BTC</option>-->
                        <option value="2">ASSET</option>
                        <option value="3">USDT</option>
                        <option value="5">EASY</option>

                        <option value="6">ETH</option>
                        <option value="7">BTC</option>
                        <option value="8">EOS</option>
                        <!--<option value="4">WFX</option>-->
                        <!--<option value="4">ASSET</option>-->
                    </select>
                </div>
                <div style=" height:50px;">
                    <div class="col-xs-4 t3" style=" float:left; height:50px; line-height:50px; padding-left:15px; color:#808bab;"> {:L('_TBDZ_')}</div>  
                    <div class="col-xs-8" style=" float:left; height:50px; line-height:50px;"> 
                        <!--<input type="text" id="address" placeholder="{:L('_SRCZDZ_')}" class="inputys" >-->
                        <input type="text" id="address" placeholder="请输入提币地址" class="inputys" >
                    </div>
                </div>
                <div class="line1"></div>  

                <div style=" height:50px;">
                <!--<div class="col-xs-4 t3" style=" float:left; height:50px; line-height:50px; padding-left:15px;"> {:L('_GBCSL_')}</div>  -->
                <div class="col-xs-4 t3" style=" float:left; height:50px; line-height:50px; padding-left:15px;"> 数量</div>
                <div class="col-xs-8" style=" float:left; height:50px; line-height:50px;">
                    <!--<input type="text" id="amount" placeholder="{:L('_SRSL1_')} " class="inputys" >-->
                    <input type="text" id="amount" placeholder="请输入提币数量" class="inputys" >
                </div>
                </div>
                <div class="line1"></div>
            <div style=" height:50px;">
                <div class="col-xs-4 t3" style=" float:left; height:50px; line-height:50px; padding-left:15px;"> 支付密码</div>
                <div class="col-xs-8" style=" float:left; height:50px; line-height:50px;">
                    <input type="password" id="password"  placeholder="请输入支付密码" class="inputys" >
                </div>
            </div>
            <div class="line1"></div>
                <!-- <div style=" height:50px;">
                <div class="col-xs-4 t3" style=" float:left; height:50px; line-height:50px; padding-left:15px;">ETH数量 ฿</div>  
                <div class="col-xs-8" style=" float:left; height:50px; line-height:50px;"> 
                    <input type="text" id="btc" placeholder="请先输入GBC数量自动计算" class="inputys" >
                </div>     
                </div>
                <div class="line1"></div> -->

            <div style=" height:50px;">
                <div class="col-xs-4 t3" style=" float:left; height:50px; line-height:50px; padding-left:15px; color:#808bab;">手机号:</div>
                <div class="col-xs-8" style=" float:left; height:50px; line-height:50px;">
                    <!--<input type="text" id="address" placeholder="{:L('_SRCZDZ_')}" class="inputys" >-->
                    <input type="text"  id="phone" value="{$userData.username}" disabled   placeholder="" class="inputys" >
                </div>
            </div>
            <if condition="$userData.type eq 1">
                <div style=" height:50px;">
                    <div class="col-xs-4 t3" style=" float:left; height:50px; line-height:50px; padding-left:15px;">短信验证</div>
                    <div class="col-xs-8" style=" float:left; height:50px; line-height:50px;">
                        <input type="text" id="code" placeholder="{:L('_SRYZM_')}" class="inputys" style="width: 58%;">
                        <div class="getCode" style="width: 19%;" id="send_message">获取</div>
                    </div>
                </div>
                <else/>
                <div style=" height:50px;">
                    <div class="col-xs-4 t3" style=" float:left; height:50px; line-height:50px; padding-left:15px;">邮箱验证</div>
                    <div class="col-xs-8" style=" float:left; height:50px; line-height:50px;">
                        <input type="text" id="code2" placeholder="{:L('_SRYZM_')}" class="inputys" style="width: 58%;">
                        <div class="getCode get-code" style="width: 19%;" id="send_email">获取</div>
                    </div>
                </div>
            </if>

                <div class="line1"></div>
                  
                <!--<div style=" height:50px;">-->
                    <!--<div class="col-xs-4" style="  height:50px; line-height:50px;  color:#475377;">{:L('_ZHYE_')}:</div>  -->
                    <!--<div class="col-xs-8" style=" height:50px; line-height:50px; color:#fff; font-size:18px;">-->
                    <!--{$userData['reward1']} GBC-->
                    <!--</div>-->
                <!--</div>-->

            <div style=" height:50px;">
                <div class="col-xs-4 t3" style=" float:left; height:50px; line-height:50px; padding-left:15px; color:#808bab;">{:L('_ZHYE_')}:</div>
                <div class="col-xs-8" style=" float:left; height:50px; line-height:50px;">
                    <!--<input type="text" id="address" placeholder="{:L('_SRCZDZ_')}" class="inputys" >-->
                    <!--<input type="text" id="balance" value="{$accountBalance}" placeholder="" class="inputys" disabled>-->
                    <input type="text" id="balance" value="{$accountBalance}" placeholder="" class="inputys" disabled>
                </div>
            </div>
            </div> 
          
            <!--<div style=" color:#475377; margin-top:15px;">-->
                <!--<img src="__IMG__/tt.png" width="18" height="18"  />-->
                <!--{:L('_TS5_')}{$configData['canshu1']} GBC {:L('_TS6_')}-->
            <!--</div>-->
      <!--       <div style=" color:#475377; margin-top:15px;">
                <img src="__IMG__/tt.png" width="18" height="18"  />
                BTC当前价格：{$btcPrice} USDT。
            </div>   -->
            <div style=" color:#475377; margin-top:15px;">
                <img src="__IMG__/tt.png" width="18" height="18"  />
                <!--{:L('_GBCYSJG_')}：1GBC = 1CNY。-->
                手续费<span id="charge"></span>%

            </div> 
            <div style=" margin-top:60px;">
                <button id="btn-1">  {:L('_QRTB_')} </button>
            </div>
          
 </div>
    <input type="hidden" id="ptr67" value="{$config.ptr67}"/>
    <input type="hidden" id="ptr75" value="{$config.ptr75}"/>
    <!--EASY手续费-->
    <input type="hidden" id="ptr76" value="{$config.ptr76}"/>
</body>
<style>
    .change-gray {
        color: #999;
    }
</style>
</html>

<!-- <script type="text/javascript">
    $("#amount").bind('input propertychange',function(){
        var fee = "{$configData['canshu1']}";
        var amount = $("#amount").val();
        var btc = "{$btcPrice}";
        var count= (amount - fee) / btc;
        $("#btc").val(count.toFixed(8));    
    });
</script> -->
<script type="text/javascript" src="__JS__/web3.1.js"></script>
<script type="text/javascript">
    // let val1=$("#ptr73").val();
    let val1=$("#ptr67").val();
    $("#charge").text(parseFloat(val1)*100);
    $('#coinname').change(function(){

        var coinname = $("#coinname").val();

        if (coinname==='2'){
            let val2=$("#ptr67").val();
            $("#charge").text(parseFloat(val2)*100);
        }
        if (coinname==='3'){
            let val3=$("#ptr75").val();
            $("#charge").text(parseFloat(val3)*100);
        }
        if (coinname==='5'){
            let val5=$("#ptr76").val();
            $("#charge").text(parseFloat(val5)*100);
        }
        console.log(coinname);
        //传输数据
        $.ajax({
            type : 'POST',
            url:"{:U('Finance/getBalance')}",
            dataType : 'json',
            data:{
                coinname:coinname,
            },
            success : function(data){

                if(data.code == 1){
                    //alert(data.msg);
                }else
                {
                    $("#balance").val(data.data);
                }
            }
        })
    });
</script>

<script type="text/javascript">
    $("#send_email").click(function(){
        var num=59;
        var that=$(this);
        //判断是否已经发送验证码
        if($(this).hasClass('change-gray'))
        {
            layer.msg("{:L('_WCF_')}",{time:1000});
            return;
        }
        // var mail = $('#mail').val();
        var mail = "{$userData['username']}";
        if(mail == '')
        {
            layer.msg("{:L('_SRSJH_')}",{time:1000});
            return false;
        }
        $.ajax({
            type : 'POST',
            url: "{:U('Public/send_email')}",
            dataType: 'json',
            data:{
                mail: mail,
            },
            success : function(data){
                var timer=setInterval(function(){
                    that.attr('id','');
                    that.text(num+'s');
                    that.addClass('active');
                    num--;
                    if(num==0){
                        that.attr('id','send_email');
                        clearInterval(timer);
                        that.text('重新发送');
                    }
                },1000);
                $(".getCode").attr("disabled",true).css("pointer-events","none");

                if(data.code > 0)
                {
                    layer.msg(data.message,{time:1000});
                }else
                {
                    layer.msg(data.message,{time:1000});
                }
            }
        })
    });
    $("#send_message").click(function(){
        var num=59;
        var that=$(this);
    var mobile = "{$userData['username']}";

        $.ajax({
            type : 'POST',
            url: "{:U('Public/send_msg')}",
            dataType: 'json',
            data:{
                mobile: mobile,
            },           
            success : function(data){
                var timer=setInterval(function(){
                    that.attr('id','');
                    that.text(num+'s');
                    that.addClass('active');
                    num--;
                    if(num==0){
                        that.attr('id','send_message');
                        clearInterval(timer);
                        that.text('重新发送');
                    }
                },1000);
                $(".getCode").attr("disabled",true).css({"pointer-events":"none","width":"35%"});

                if(data.code > 0)
                {
                    layer.msg(data.message,{time:1000});
                }else
                {
                    layer.msg(data.message,{time:1000});
                }
            }
        }) 
    }); 

</script>

<script type="text/javascript">
    if (typeof web3 !== 'undefined') {
        web3 = new Web3(web3.currentProvider);
    }
    else {
        // infura申请的地址
        web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/v3/96e3bf3bd1164bc4a5d8d9bb3dca6d3c"));
        // web3 = new Web3('https://mainnet.infura.io/JLEYzEEavNnSni91CvPF');
    }


    $('#btn-1').click(function(){
        layer.confirm("确定提币吗？",function () {
            //生成BTC地址
            var coinname = $("#coinname").val();
            var address = $("#address").val();

            //验证钱包地址
            if(coinname!=='1'){
                //验证数量
                if(!web3.utils.isAddress(address)){
                    alert('钱包地址不正确');
                    return false;
                }
            }


            var amount = $("#amount").val();
            var password = $("#password").val();
            var phone = $("#phone").val();
            // 20191112
            var type = "{$userData['type']}";
            if(type=='1'){
                var getCode = $("#code").val();
            }else{
                var getCode = $("#code2").val();
            }

            if(getCode===''){
                alert("请填写验证码");return false;
            }
            //传输数据
            $.ajax({
                type : 'POST',
                url:"__ACTION__",
                // url:"{:U('Property/zhuanzhang')}",
                dataType : 'json',
                data:{
                    coinname:coinname,
                    address:address,
                    amount:amount,
                    password:password,
                    phone:phone,
                    getCode:getCode
                },
                success : function(data){

                    if(data.code == 1){
                        layer.msg(data.msg,{time:1000});
                        return false;
                        // alert(data.msg);
                        //setTimeout(function(){ window.location.reload(); }, 1000);
                    }else
                    {
                        layer.msg(data.msg,{time:1000});
                        // alert(data.msg);
                        setTimeout(function(){ window.location.href="{:U('Finance/wallet')}"; }, 1000);
                    }
                }
            })
        });

    });

// $("#btn-1").click(function(){
//
//     var balance = "{$userData['reward1']}";
//     var fee = "{$configData['canshu1']}";
//     var min = "{$configData['canshu17']}";
//     var amount = $("#amount").val();
//     var address = $("#address").val();
//     var code = $("#code").val();
//     //var btc = $("#btc").val();
//
//     if(amount == '' || address == '' || code == ''){
//         layer.msg("{:L('_TBXX_')}",{time:1000});
//         return false;
//     }
//
//     if(parseFloat(amount) < parseFloat(min))
//     {
//         layer.msg("{:L('_TBBXY_')}"+"{$configData['canshu17']}",{time:1000});
//         return false;
//     }
//
//     if(parseFloat(amount) + parseFloat(fee) > parseFloat(balance))
//     {
//         layer.msg("{:L('_ZHYEBZ_')}",{time:1000});
//         return false;
//     }
//
//     $.ajax({
//         type: 'POST',
//         url: "__ACTION__",
//         dataType: 'json',
//         data: {
//             amount:amount,
//             address:address,
//             code:code
//         },
//         success: function(data){
//              if(data.code>0){
//                 layer.msg(data.message,{time:1000});
//
//                 window.location.href="{:U('Finance/withdraw')}";
//              }
//              else{
//                 layer.msg(data.message,{time:1000});
//              }
//         }
//     })
// });

</script>
